package com.example.pucha_xian.common;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.pucha_xian.R;

import cn.hzw.doodle.DoodleActivity;
import cn.hzw.doodle.DoodleParams;
import cn.hzw.doodle.DoodleView;

public class Ablum {

    //照片涂鸦
    public static void Doodle(Activity activity, String name, int request){
        if(name==null){
            Toast.makeText(activity,"还未输入点名或未添加照片", Toast.LENGTH_LONG).show();
            return;
        }
        // 涂鸦参数
        DoodleParams params = new DoodleParams();
        params.mIsFullScreen = true;
        // 图片路径
        params.mImagePath = PhotoConfig.sdCard + PhotoConfig.PHOTO_PATH + name;
        Log.e("photo",""+name);
        // 保存路径
        params.mSavePath = PhotoConfig.sdCard + PhotoConfig.PHOTO_PATH + name;
        // 初始画笔大小
        params.mPaintUnitSize = DoodleView.DEFAULT_SIZE;
        // 画笔颜色
        params.mPaintColor = Color.RED;
        // 是否支持缩放item
        params.mSupportScaleItem = true;
        // 启动涂鸦页面
        DoodleActivity.startActivityForResult(activity, params, request);
    }


    public static void imageMax(String path, Context context, Boolean bool) {

        LayoutInflater inflater = LayoutInflater.from(context);
        @SuppressLint("InflateParams") View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null);
        // 加载自定义的布局文件
        final AlertDialog dialog = new AlertDialog.Builder(context).create();
        ImageView img = (ImageView) imgEntryView.findViewById(R.id.large_image);
        if(bool){
            img.setImageBitmap(PhotoConfig.showPhoto(path));
            //加载本地图片
        }else {
            Glide.with(context).load(path).into(img);
            // 这个是加载网络图片的，可以是自己的图片设置方法
        }
        // imageDownloader.download(imageBmList.get(0),img);
        dialog.setView(imgEntryView); // 自定义dialog
        dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        dialog.show();
        // 点击布局文件（也可以理解为点击大图）后关闭dialog，这里的dialog不需要按钮
        imgEntryView.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                dialog.cancel();
            }
        });
    }

}
